import { defineConfig } from '@vue/cli-service'
import path from 'path'
import { fileURLToPath } from 'url'
import Components from 'unplugin-vue-components/webpack'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

export default defineConfig({
  publicPath: './',  // 保持相对路径
  transpileDependencies: true,
  lintOnSave: false,
  
  // 配置别名
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    plugins: [
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  },

  // 开发服务器配置
  devServer: {
    historyApiFallback: true,
    port: 9000,
    open: true,
    proxy: {
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true
      }
    }
  }
})
